<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%
	String DRV = "org.mariadb.jdbc.Driver";
	String URL = "jdbc:mariadb://localhost:3306/jwj8508?user=jwj8508&password=123456";	
	String sql = "select * from memberv4 where uid=? and pwd=?";
	
	Connection conn = null;
	PreparedStatement pstmt = null;
	ResultSet rs = null;
%>
<%
	boolean isLogin = false;
	String uid = request.getParameter("uid");
	String pwd = request.getParameter("pwd");	
%>
<%
	try {
		Class.forName(DRV);
		conn = DriverManager.getConnection(URL);
		pstmt = conn.prepareStatement(sql);
		pstmt.setString(1, uid);
		pstmt.setString(2, pwd);
		rs = pstmt.executeQuery();		
		if (rs.next()) {
			isLogin = true;
		}
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		if (rs!=null)try{rs.close();}catch(Exception e){}
		if (pstmt!=null)try{pstmt.close();}catch(Exception e){}
		if (conn!=null)try{conn.close();}catch(Exception e){}
	}
%>
<!DOCTYPE html>
<html lang="ko">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<title>JSP 프로젝트 v1</title>
		<link type="text/css" href="../css/layout.css" rel="stylesheet" />
		<style type="text/css">			
			form {
				width: 270px;
				margin: 0 auto;
			}
			label {
				display: inline-block;
				width: 80px;
				margin-right: 5px;
				text-align: right;
				font-weight: bold;
			}
			form div {
				margin-bottom: 10px;
			}
		</style>
		
	</head>
	<body>
		<div>
			<h1>JSP 프로젝트 v1</h1> <!-- 제목 -->
			<ul id="nav">
				<li><a href="../index.jsp">Home</a></li>
				<li><a href="join.jsp">회원가입</a></li>
				<li><a href="login.html">로그인</a></li>
				<li><a href="../board/list.jsp">게시판</a></li>
				<li><a href="myinfo.jsp">회원정보</a></li>
			</ul> <!-- 상단메뉴 -->
			<hr />
		</div> <!-- header -->
		
		<div id="content">
			<% if (isLogin) { %>
			<h2>로그인 결과 성공!</h2>			
			<p>입력한 아이디 : <%=uid %></p>
			<p>입력한 비밀번호 : <%=pwd %></p>
			<p><a href="myinfo.jsp?uid=<%=uid %>">회원정보 확인하기</a></p>
			<% } else if (!isLogin) { %>
			<h2>로그인 실패</h2>			
			<p>입력한 아이디 및 비밀번호를 다시 한번 확인하세요.</p>
			<p><a href="login.html">다시 로그인하기</a></p>
			<% } %>				
		</div> <!-- content -->
		
		<div>
			<hr />
			<p id="copy">Copyright &copy; 2013 JINn. All right reserved.</p>
		</div> <!-- footer -->
		
		
	</body>
</html>
